
//
// 120717 - AH - (Midtun) Created.
//

package org.soekrat.environment.event;

import org.soekrat.conversationevent.ConversationEvent;
import org.soekrat.environment.Orb;
import org.soekrat.environment.Sensor;

/**
 * <p>
 *   Event published by
 *   {@link Sensor}s to
 *   {@link SensorListener}s.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC)
 */
public final class SensorEvent extends ConversationEvent
{ 
  private final String m_dataType;
  
  private final Object m_data;
  
  /**
   * <p>
   *   Constructor.  
   * </p>
   * @param sensor Event's source.
   */
  public SensorEvent(Sensor sensor, Orb orb, Object data, String dataType)
  { 
    super(sensor, orb);
    
    if (orb==null)
    {
      throw new NullPointerException("orb");
    }
    if (data==null)
    {
      throw new NullPointerException("data");
    }
    if (dataType==null)
    {
      throw new NullPointerException("dataType");
    }
    
    m_data=data;
    m_dataType=dataType;
  }
  
  /**
   * <p>
   *   Gets sensed data.
   * </p>
   * @return Data.
   */
  public Object getData(){ return m_data; }
  
  /**
   * <p>
   *   Gets type name of data sensed.
   * </p>
   * @return Name.
   */
  public String getDataType(){ return m_dataType; }
  
  @Override
  public String toString()
  {
    StringBuilder sb=new StringBuilder();
    sb.append("data-type: ").append(m_dataType).append(", data: ")
      .append(m_data);
    return sb.toString();
  }
  
}
